<template>
  <div>
        <div>
                                <el-upload
                                    :action=this.url
                                    ref="upload"
                                    :auto-upload="false"
                                  :http-request="uploadFile"
                                    multiple
                                    :limit="3"       
                                >
                                    <i class="el-icon-plus"></i>
                                </el-upload>
                                <span slot="footer" class="dialog-footer">
                                    <el-button @click="resetForm()">取 消</el-button>
                                    <el-button type="primary" @click="submitForm()">确 定</el-button>
                                </span>
                            </div>
  </div>
</template>
<script>
  import {getToken} from "@/utils/auth";
  export default {
    name: "Declare",
    data() {
      return {
        // 表单参数process.env.VUE_APP_BASE_API
        img:'',
        url: "http://wubu.xzrenli.cn/file/uploadfilePIC",
      };
    },
    methods:{
      uploadFile(file) {
        this.formData.append('file', file.file);
      },
      async submitForm() {
        this.formData = new FormData();
        this.$refs.upload.submit();
        this.formData.append('type', 'file'); //其他参数
        let config = {
          headers: {Authorization: "Bearer " + getToken()},
        };
        //这个类型必选写
        const { data: res } = await this.$axios.post('http://wubu.xzrenli.cn/file/uploadfilePIC', this.formData, config);
        console.log(res.url);
        this.img=res.url
        this.$emit('event1',  this.img)
        // this.picture = res.result;
      },
    }
  };
</script>

